#include "VariableDeclarationNode.h"

#include "Output/Console.h"
#include "ScriptCompiler/Token/Token.h"
#include "ScriptCompiler/AST/TypeNode.h"
#include "ScriptCompiler/AST/DecoratorNode.h"


void CVariableDeclarationNode::DebugPrint(int32_t InDepth)
{
    //print depth
    for (int32_t i = 0; i < InDepth; ++i)
    {
        WH::Print(U'\t');
    }

    //print decorator
    if(Decorator.HasValue())
    {
        Decorator.GetValue()->DebugPrint(0);
    }

    //print type 
    Type->DebugPrint(0);


    //print name
    WH::Print(U' ' + Name->ToString());

    if(InitialValue)
    {
        WH::Print(U'=');

        InitialValue->DebugPrint(0);
    }

    WH::Print(U";\n");
}


std::shared_ptr<CScriptToken> CVariableDeclarationNode::GetFirstToken()
{
    if(Decorator.HasValue())
    {
        return Decorator.GetValue()->GetFirstToken();
    }

    return Type->GetFirstToken();
  
}
